package com.longxi.tianjintianbao.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.longxi.tianjintianbao.AppConst;
import com.longxi.tianjintianbao.ui.fragment.houseinspection.RuZhuYanFangFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DingCuiLin on 2016/8/26.
 */

public class HomeInspectionPagerAdapter extends FragmentPagerAdapter {

    private List<Fragment> mFragmentList;
    private String[] mTitles_3;
    private Fragment mCurFragment;

    public HomeInspectionPagerAdapter(FragmentManager fm, String[] mTitles_3) {
        super(fm);
        mFragmentList = new ArrayList<>();
        this.mTitles_3 = mTitles_3;
        Fragment f1 = new RuZhuYanFangFragment().setArguments(AppConst.YAN_FANG_RUZHU);
        Fragment f2 = new RuZhuYanFangFragment().setArguments(AppConst.YAN_FANG_TUIZHU);
        Fragment f3 = new RuZhuYanFangFragment().setArguments(AppConst.YAN_FANG_ZICHAN);
        mFragmentList.add(f1);
        mFragmentList.add(f2);
        mFragmentList.add(f3);
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList != null ? mFragmentList.size() : 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles_3[position];
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        mCurFragment = (Fragment) object;
    }

    public Fragment getCurrentFragment() {
        return mCurFragment;
    }
}
